/**
 * 
 */
package lelouet.datacenter.simulation.vms;

import lelouet.datacenter.simulation.VM;

public abstract class AVM extends PhysicalRequirementsImpl implements VM {

	/**
	 * @param id
	 *            the id of the vm.
	 * @param time
	 *            the time the vm was created at
	 */
	public AVM(String id, long time) {
		this.id = id;
		this.time = time;
	}

	protected String id;

	public String getId() {
		return id;
	}

	/** last time this stopped working */
	protected long time;

	/** @return the last slot time this machine stopped working */
	public long getTime() {
		return time;
	}

	/**
	 * set the present time
	 */
	public void setTime(long time) {
		this.time = time;
	}

	protected long cpuWeight = 1;

	@Override
	public long getWeightCPU() {
		return cpuWeight;
	}

	@Override
	public void setCPUWeight(long weight) {
		cpuWeight = weight;
	}

	/** the CPU this will use for next works */
	private long allocatedCPU = 0L;

	@Override
	public void setAllocatedCPU(long MIPS) {
		allocatedCPU = MIPS;
	}

	@Override
	public long getAllocatedCPU() {
		return allocatedCPU;
	}

	@Override
	public String toString() {
		return getId() + ":" + super.toString();
	}
}
